﻿using System;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using QuickTest.Core.Compilation;

namespace QuickTest.Tests.Services.TextRetrieval
{
    [TestFixture]
    public class DirectoryUriTests
    {
        private const string DirectoryPath = "c:/Temp/";
        private const string FileUriString = "c:/Temp/TestUtils.txt";
        private const string NonFileUriString = "http://www.something.com";

        [Test]
        public void ArgumentException_Thrown_If_Null_Uri_Passed()
        {
            TestUtils.AssertThrows<ArgumentNullException>(() => new DirectoryUri(null), "ArgumentNullException should have been thrown.");
        }

        [Test]
        public void ArgumentException_Thrown_If_Uri_Is_File_Uri()
        {
            Exception ex = TestUtils.AssertThrows<ArgumentException>(() => new DirectoryUri(FileUriString), "ArgumentException should have been thrown.");

            Assert.That(ex.Message, Is.EqualTo("Uri must be a directory uri"), "Exception message should have been 'Uri must be a directory uri'");
        }

        [Test]
        public void ArgumentException_Thrown_If_Uri_Is_Not_File_Uri()
        {
            Exception ex = TestUtils.AssertThrows<ArgumentException>(() => new DirectoryUri(NonFileUriString), "ArgumentException should have been thrown.");

            Assert.That(ex.Message, Is.EqualTo("Uri must be a directory uri"), "Exception message should have been 'Uri must be a directory uri'");
        }

        [Test]
        public void Can_Get_Uri_AbsolutePath()
        {
            var uri = new Uri(DirectoryPath);
            var directoryUri = new DirectoryUri(DirectoryPath);

            Assert.That(directoryUri.AbsolutePath, Is.EqualTo(uri.AbsolutePath), "DirectoryUri.AbsolutePath should be equal to Uri.AbsolutePath");
        }
    }
}